package com.zgjkhis.modules.system.rest;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zgjkhis.logging.aop.log.Log;
import com.zgjkhis.modules.security.security.LoginUserUtil;
import com.zgjkhis.modules.system.domain.Department;
import com.zgjkhis.modules.system.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @date 2018-11-23
 */
@Api(tags = "基础设置：科室管理")
@RestController
@RequestMapping("/api/department")
public class DepartmentController {

    private static final String ENTITY_NAME = "department";
    private final DepartmentService departmentService;

    public DepartmentController(DepartmentService departmentService) {

        this.departmentService = departmentService;
    }

    @Log("查询科室管理")
    @ApiOperation("查询科室管理")
    @GetMapping(value = "/list")
    public ResponseEntity<Object> getSuppliers(){
        List<Department> list=new ArrayList<>();
        list = departmentService.list(Wrappers.<Department>query().lambda().eq(Department::getStatus,1)
                .and(wrapper ->wrapper.eq(Department::getType,"0").or().eq(Department::getCreateUser,LoginUserUtil.getPharmId())));
        return new ResponseEntity<>(list,HttpStatus.OK);
    }

}
